from django.http import HttpResponse
from django.shortcuts import render

# Create your views here.

"""
    视图函数
    通过路由访问函数返回的响应数据
"""


def helloworld(request):
    return HttpResponse("Hello World")


def acticle_create(request):
    return HttpResponse('创建一篇文章')


def acticle_detail(request, acticle_id, title):
    return HttpResponse(f'当前文章页面id为{acticle_id}，标题是{title}')


def phone_detail(request, phone_number):
    return HttpResponse(f'当前手机号是{phone_number}')


def list(request):
    author = 'ld'
    acticle_number = '20'
    acticle_list = [
        '第一篇文章: 什么是django',
        '第二篇文章: django的mvt模式',
        '第三片文章: django的视图'
    ]

    info = {
        'name': 'ld',
        'age': 18,
        'programming_langauge': ['python', 'java', 'c']
    }

    content = """
    <div class="anony-nav-links">
      <ul>
        <li>
          <a target="_blank" class="lnk-book" href="https://book.douban.com">豆瓣读书</a>
        </li>
        <li>
          <a target="_blank" class="lnk-movie" href="https://movie.douban.com">豆瓣电影</a>
        </li>
        <li>
          <a target="_blank" class="lnk-music" href="https://music.douban.com">豆瓣音乐</a>
        </li>
        <li>
          <a target="_blank" class="lnk-events" href="https://www.douban.com/location/">豆瓣同城</a>
        </li>
        <li>
          <a target="_blank" class="lnk-group" href="https://www.douban.com/group/">豆瓣小组</a>
        </li>
        <li>
          <a target="_blank" class="lnk-read" href="https://read.douban.com">豆瓣阅读</a>
        </li>
        <li>
          <a target="_blank" class="lnk-fm" href="https://fm.douban.com">豆瓣FM</a>
        </li>
        <li>
          <a target="_blank" class="lnk-shijian" href="https://time.douban.com/?dt_time_source=douban-web_anonymous_index_top_nav">豆瓣时间</a>
        </li>
        <li>
          <a target="_blank" class="lnk-market" href="https://market.douban.com?utm_campaign=anonymous_top_nav&utm_source=douban&utm_medium=pc_web">豆瓣豆品</a>
        </li>
      </ul>
    </div>
    """

    return render(request, 'list.html', {
        'author': author,
        'number': acticle_number,
        'acticle_list': acticle_list,
        'info': info,
        'content': content
    })
